package org.jivesoftware.smackx.pubsub.provider;

import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.pubsub.Item;
import org.jivesoftware.smackx.pubsub.PayloadItem;
import org.jivesoftware.smackx.pubsub.SimplePayload;
import org.xmlpull.v1.XmlPullParser;

public class ItemProvider
  implements PacketExtensionProvider
{
  public PacketExtension parseExtension(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    Object localObject;
    String str1 = paramXmlPullParser.getAttributeValue(null, "id");
    String str2 = paramXmlPullParser.getName();
    int i = paramXmlPullParser.next();
    if (i == 3)
      localObject = new Item(str1);
    while (true)
    {
      String str3;
      String str4;
      int j;
      StringBuilder localStringBuilder;
      while (true)
      {
        return localObject;
        str3 = paramXmlPullParser.getName();
        str4 = paramXmlPullParser.getNamespace();
        if (ProviderManager.getInstance().getExtensionProvider(str3, str4) != null)
          break label187;
        j = 0;
        localStringBuilder = new StringBuilder();
        if (j == 0)
          break;
        localObject = new PayloadItem(str1, new SimplePayload(str3, str4, localStringBuilder.toString()));
      }
      if ((i == 3) && (paramXmlPullParser.getName().equals(str2)))
        j = 1;
      while (true)
      {
        do
          while (true)
          {
            if (j != 0);
            i = paramXmlPullParser.next();
          }
        while ((i == 2) && (paramXmlPullParser.isEmptyElementTag()));
        localStringBuilder.append(paramXmlPullParser.getText());
      }
      label187: localObject = new PayloadItem(str1, PacketParserUtils.parsePacketExtension(str3, str4, paramXmlPullParser));
    }
  }
}